<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/base_body_header.jsp" %>
<%@include file="../common/navbar.jsp" %>
<%@include file="../common/page_content_pre.jsp" %>
<div class="page-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="widget-box">
                <div class="widget-header">
                    <h4>${not empty cours.id?'修改':'添加'}课程</h4>
                </div>

                <div class="widget-body">
                    <div class="widget-main no-padding">
                        <form class="form-horizontal" modelAttribute="course"
                              action="${GLOBAL.basePath}/course/save" method="post" id="coursForm">
                            <input name="id" id="id" type="hidden" value="${cours.id}"/>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">课程名：</label>

                                    <div class="col-sm-5">
                                        <input id="coursName" name="coursName" type="text" class="input-xlarge required"
                                               maxlength="50" value="${cours.coursName}">
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">课程类型：</label>

                                    <div class="col-sm-5">
                                        <select id="coursType" name="coursType" class="input-xlarge"
                                                def_value="${cours.coursType}">
                                            <option value="1">普通</option>
                                        </select>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">课程级别：</label>

                                    <div class="col-sm-5">
                                        <select id="level" name="level" class="input-xlarge">
                                            <option value="1">普通</option>
                                            <option value="2">优先</option>
                                        </select>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">课程数量：</label>

                                    <div class="col-sm-5">
                                        <input id="count" name="count" type="text" class="input-xlarge"
                                               maxlength="50" value="${cours.count}">
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">课程序号：</label>

                                    <div class="col-sm-5">
                                        <input id="courseNumber" name="courseNumber" type="text" class="input-xlarge required"
                                               maxlength="50" value="${cours.courseNumber}">
                                        <%--<select id="courseNumber" name="courseNumber" class="input-xlarge"--%>
                                                <%--def_value="${cours.courseNumber}">--%>
                                            <%--<option value="1">第1课时</option>--%>
                                            <%--<option value="2">第2课时</option>--%>
                                            <%--<option value="3">第3课时</option>--%>
                                            <%--<option value="4">第4课时</option>--%>
                                            <%--<option value="5">第5课时</option>--%>
                                            <%--<option value="6">第6课时</option>--%>
                                            <%--<option value="7">第7课时</option>--%>
                                            <%--<option value="8">第8课时</option>--%>
                                            <%--<option value="9">第9课时</option>--%>
                                            <%--<option value="10">第10课时</option>--%>
                                            <%--<option value="11">第11课时</option>--%>
                                            <%--<option value="12">第12课时</option>--%>
                                            <%--<option value="13">第13课时</option>--%>
                                            <%--<option value="14">第14课时</option>--%>
                                            <%--<option value="15">第15课时</option>--%>
                                            <%--<option value="16">第16课时</option>--%>
                                            <%--<option value="17">第17课时</option>--%>
                                            <%--<option value="18">第18课时</option>--%>
                                            <%--<option value="19">第19课时</option>--%>
                                            <%--<option value="20">第20课时</option>--%>
                                            <%--<option value="21">第21课时</option>--%>
                                        <%--</select>--%>
                                        <span class="help-inline"><font color="red">*</font> </span>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <input id = "videoUrl" name = "videoUrl" type="hidden">
                                    <label class="col-sm-3 control-label">添加视频：</label>
                                    <div class="col-sm-6">
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <div id="upload">
                                                    <p><button type="button" class="btn btn-sm btn-info">上传视频</button></p>
                                                </div>
                                            </div>
                                            <div class="layui-inline" id="upload_preview"></div>
                                        </div>

                                        <div class="layui-form-item layui-hide" id="upload_progress">
                                            <label class="layui-form-label"></label>

                                            <div class="layui-input-inline" style="width:21%;">
                                                <div class="layui-progress" lay-showpercent="true"
                                                     lay-filter="upload_progress">
                                                    <div class="layui-progress-bar layui-bg-blue"
                                                         lay-percent="0%"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">视频说明：</label>

                                    <div class="col-sm-7">
                                        <input id="vidoeDesc" name="vidoeDesc" type="text" class="form-control"
                                               maxlength="100" value="${cours.vidoeDesc}">
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">添加音频：</label>
                                    <input id = "audioUrl" name = "audioUrl" type="hidden">
                                    <div class="col-sm-6">
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <div id="uploadAudio">
                                                    <p><button type="button" class="btn btn-sm btn-info">上传音频</button></p>
                                                </div>
                                            </div>
                                            <div class="layui-inline" id="uploadAudio_preview"></div>
                                        </div>

                                        <div class="layui-form-item layui-hide" id="uploadAudio_progress">
                                            <label class="layui-form-label"></label>

                                            <div class="layui-input-inline" style="width:21%;">
                                                <div class="layui-progress" lay-showpercent="true"
                                                     lay-filter="uploadAudio_progress">
                                                    <div class="layui-progress-bar layui-bg-blue"
                                                         lay-percent="0%"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">音频说明：</label>

                                    <div class="col-sm-7">
                                        <input id="audioDesc" name="audioDesc" type="text" class="form-control"
                                               maxlength="100" value="${cours.audioDesc}">
                                    </div>
                                </div>
                            </fieldset>

                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">描述：</label>

                                    <div class="col-sm-6">
                                        <textarea id="content" name="content" type="text" class="form-control"
                                             rows="8"  maxlength="200">${cours.content}</textarea>
                                    </div>
                                </div>
                            </fieldset>

                            <div class="form-actions center">
                                <button type="button" class="btn btn-sm btn-grey" id="go_back_btn">
                                    返回
                                    <i class="icon-reply icon-on-right bigger-110"></i>
                                </button>
                                <shiro:hasPermission name='sys:course:edit'>
                                    <button type="submit" class="btn btn-sm btn-success" id="save_btn">
                                        保存
                                        <i class="icon-save icon-on-right bigger-110"></i>
                                    </button>
                                </shiro:hasPermission>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<%@include file="../common/page_content_suf.jsp" %>
<%@include file="../common/script.jsp" %>
<%@include file="../common/css.jsp" %>

<script type="text/javascript">
    $(document).ready(function () {
        $("#coursName").focus();
        <%--$("#coursForm").validate({--%>
            <%--rules: {--%>
                <%--coursName: {--%>
                    <%--remote: {--%>
                        <%--type: "POST",--%>
                        <%--cache: false,--%>
                        <%--url: "${GLOBAL.basePath}/cours/checkName",--%>
                        <%--data: {--%>
                            <%--oldName: function () {--%>
                                <%--return "${sysRole.name}";--%>
                            <%--}--%>
                        <%--}--%>
                    <%--}--%>
                <%--},--%>

                <%--courseNumber: {--%>
                    <%--required:true,--%>
                    <%--range: [0,$("#count").val()]--%>
                <%--}--%>
            <%--},--%>
            <%--messages: {--%>
                <%--coursName: {required: "课程名不能为空", remote: jQuery.format("课程名已存在")},--%>
                <%--range : "请输入范围在0到"+$("#count").val()+"之间的数",--%>

            <%--},--%>
        <%--});--%>

        $("#go_back_btn").on("click", function () {
            goBack();
        });
    });

    function goBack() {
        document.location.href = "${GLOBAL.basePath}/course/list";
    }
</script>
